Optimal. Leaf size=59 \[ \frac{a x}{b^2}-\frac{2 \sqrt{a-b} \sqrt{a+b} \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{x}{2}\right )}{\sqrt{a+b}}\right )}{b^2}-\frac{\sin (x)}{b} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.108881, antiderivative size = 59, normalized size of antiderivative = 1., number of steps used = 4, number of rules used = 4, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.308, Rules used = {2695, 2735, 2659, 205} \[ \frac{a x}{b^2}-\frac{2 \sqrt{a-b} \sqrt{a+b} \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{x}{2}\right )}{\sqrt{a+b}}\right )}{b^2}-\frac{\sin (x)}{b} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 2695
Rule 2735
Rule 2659
Rule 205
Rubi steps
\begin{align*} \int \frac{\sin ^2(x)}{a+b \cos (x)} \, dx &=-\frac{\sin (x)}{b}-\frac{\int \frac{-b-a \cos (x)}{a+b \cos (x)} \, dx}{b}\\ &=\frac{a x}{b^2}-\frac{\sin (x)}{b}+\left (1-\frac{a^2}{b^2}\right ) \int \frac{1}{a+b \cos (x)} \, dx\\ &=\frac{a x}{b^2}-\frac{\sin (x)}{b}+\left (2 \left (1-\frac{a^2}{b^2}\right )\right ) \operatorname{Subst}\left (\int \frac{1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )\\ &=\frac{a x}{b^2}-\frac{2 \sqrt{a-b} \sqrt{a+b} \tan ^{-1}\left (\frac{\sqrt{a-b} \tan \left (\frac{x}{2}\right )}{\sqrt{a+b}}\right )}{b^2}-\frac{\sin (x)}{b}\\ \end{align*}
Mathematica [A] time = 0.0788361, size = 54, normalized size = 0.92 \[ \frac{-2 \sqrt{b^2-a^2} \tanh ^{-1}\left (\frac{(a-b) \tan \left (\frac{x}{2}\right )}{\sqrt{b^2-a^2}}\right )+a x-b \sin (x)}{b^2} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [B] time = 0.076, size = 108, normalized size = 1.8 \begin{align*} -2\,{\frac{\tan \left ( x/2 \right ) }{b \left ( \left ( \tan \left ( x/2 \right ) \right ) ^{2}+1 \right ) }}+2\,{\frac{\arctan \left ( \tan \left ( x/2 \right ) \right ) a}{{b}^{2}}}-2\,{\frac{{a}^{2}}{{b}^{2}\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}\arctan \left ({\frac{\tan \left ( x/2 \right ) \left ( a-b \right ) }{\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}} \right ) }+2\,{\frac{1}{\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}\arctan \left ({\frac{\tan \left ( x/2 \right ) \left ( a-b \right ) }{\sqrt{ \left ( a-b \right ) \left ( a+b \right ) }}} \right ) } \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A] time = 1.76365, size = 378, normalized size = 6.41 \begin{align*} \left [\frac{2 \, a x - 2 \, b \sin \left (x\right ) + \sqrt{-a^{2} + b^{2}} \log \left (\frac{2 \, a b \cos \left (x\right ) +{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt{-a^{2} + b^{2}}{\left (a \cos \left (x\right ) + b\right )} \sin \left (x\right ) - a^{2} + 2 \, b^{2}}{b^{2} \cos \left (x\right )^{2} + 2 \, a b \cos \left (x\right ) + a^{2}}\right )}{2 \, b^{2}}, \frac{a x - b \sin \left (x\right ) - \sqrt{a^{2} - b^{2}} \arctan \left (-\frac{a \cos \left (x\right ) + b}{\sqrt{a^{2} - b^{2}} \sin \left (x\right )}\right )}{b^{2}}\right ] \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A] time = 1.15667, size = 122, normalized size = 2.07 \begin{align*} \frac{a x}{b^{2}} + \frac{2 \,{\left (\pi \left \lfloor \frac{x}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac{a \tan \left (\frac{1}{2} \, x\right ) - b \tan \left (\frac{1}{2} \, x\right )}{\sqrt{a^{2} - b^{2}}}\right )\right )} \sqrt{a^{2} - b^{2}}}{b^{2}} - \frac{2 \, \tan \left (\frac{1}{2} \, x\right )}{{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )} b} \end{align*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]